<?php
/**********************************************************
 | CopyRight Reserved (C) Compass Technical Team  
 | Home Page: http://www.oversea.com.au/
 | Designer: Cavin Zhang
 | Date: Apr 11, 2012
 *********************************************************
 | Program Description:
 | - This is to be visted page of user posted question
 ************************************************************/
include '../classes/class.overseaSimpleUser.php';
$zTemplate->set_file ( 'main', '../templates/compass_query.html' );
$zTemplate->set_block ( 'main', 'msgMenu', 'eachAns' );
/* set the footer type */
$header_type = 'space';
$qid = $_GET['id'];
$usrInfo = array('usr_face','usr_shw_name');

$sql = "UPDATE `cs_query` SET `view` = `view` + 1 WHERE `qid`='".mysql_real_escape_string($qid)."'";
$rs = $dbObj -> executeBasicQuery($sql);
/**
 * Get the question details
 */
$sql = "SELECT * FROM `cs_query` WHERE `qid`='".mysql_real_escape_string($qid)."'";
$tRecordSet = $dbObj -> getOneQuery($sql);

if($tRecordSet){
	$zMemObj = new overseaBasicUser($tRecordSet['usr_id']);
	
	$usrInfoArray = $zMemObj ->getUsrInfo($dbObj,$usrInfo);
	//Added by Liang Fan on 20/4/2012, plus links to users' faces
	$QuestionOwnerLink = buildMemVisitedURL($zMemObj->getTempUserId(),$usrInfoArray['usr_shw_name'], getUsrType($tRecordSet['usr_id']));
	$zTemplate -> set_var(array('QT'=>$tRecordSet['title'],'QC'=>$tRecordSet['content'], 'Description'=>addslashes(substr($tRecordSet['content'], 0, 72)), 'userimg'=>filterUserFace($usrInfoArray['usr_face'],$tRecordSet['usr_id']),
							'UN'=>$usrInfoArray['usr_shw_name'],'PT'=>countTimeDiff($tRecordSet['date_time']),'RST'=>$tRecordSet['likes']-$tRecordSet['against'], 'usrLink'=>$QuestionOwnerLink,
							'qid'=>$qid,'oid'=>$tRecordSet['usr_id']));
							
	
	
							
	if($tRecordSet['status'] == 1){
		$zTemplate->set_var(array('QCLOSE'=>'[CLOSED]','qstate'=>$tRecordSet['status']));
	}
}

if(chkUsrLoggedOn()){
	$zMemObj -> setUserRealID($aususrrealid);
	$myProfile = $zMemObj -> getUsrInfo($dbObj,$usrInfo);
	$zTemplate -> set_var(array('userid'=>$aususrrealid,'userface'=>$myProfile['usr_face']));
}


/*GET THE ANSWERS*/
$sql = "SELECT * FROM `cs_query_ans` WHERE `qid` = '".mysql_real_escape_string($qid)."'  ORDER BY status DESC,aid DESC";
$aRecordSet = $dbObj -> executeQuery($sql);
if($aRecordSet)
{
	foreach ($aRecordSet as $val)
	{
		$zMemObj -> setUserRealID($val['usr_id']);
		$helperInfo = $zMemObj -> getUsrInfo($dbObj,$usrInfo);
		//Added by Liang Fan on 20/4/2012, plus links to users' faces
		$QSolverLink = buildMemVisitedURL($zMemObj->getTempUserId(),$helperInfo['usr_shw_name'], getUsrType($val['usr_id']));
		$zTemplate -> set_var(array('AC'=>nl2br($val['content']),'AT'=>countTimeDiff($val['date_time']),'AUN'=>$helperInfo['usr_shw_name'],'AIMG'=>filterUserFace($helperInfo['usr_face'],$val['usr_id']),
						'ALK'=>$QSolverLink, 'AST'=>$val['likes']-$val['against'],'aid'=>$val['aid']));
		$zTemplate->parse ( 'eachAns', 'msgMenu', true );
	}
	$zTemplate -> set_var('TTAS',count($aRecordSet));
}
else
{
	$zTemplate -> set_var('SORN','none');
}

$langPackage = array('sSpacingHeader','sDetails','charFocusTitle','sIAnswer');
?>